<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

<ui:composition>

	<!-- Le formulaire principal du hub. -->
	<h:form id="hub_form">
		<!-- Le panneau de visualisation du hub. -->
		<a4j:outputPanel id="hub_panel">
			<h:panelGrid columns="3" border="0" width="1550" 
				columnClasses="_left_hub ,_center_hub, _right_hub">

				<ui:repeat var="rail" value="#{hubManaged.hub.lstLeftRails}">
					<!-- Les voies de réception. -->
					<div id="rl_head_#{rail.id}"
						class="rail_header_small_#{rail.available}">

						<!-- Pour les rôles avec modification. -->
						<a4j:commandLink id="cl_#{rail.id}" execute="@this"
							oncomplete="dhtmlmodal.open('sort', 'iframe', 'sec_manage_sort.jsf', 
							'#{lbl['menu.hub.sort']}', 'width=950px,height=650px,center=1,
							resize=0,scrolling=0');"
							rendered="#{loginManaged.currentUser.role.role == 'ROLE_AGENCY_CHIEF' 
							|| loginManaged.currentUser.role.role == 'ROLE_COORDINATOR'}">
							<h:outputText value="#{lbl['hub.rail']} #{rail.number}" />
							<f:setPropertyActionListener target="#{hubManaged.currentRail}"
								value="#{rail}" />
						</a4j:commandLink>

						<!-- Pour les rôles sans modification. -->
						<h:outputText value="#{lbl['hub.rail']} #{rail.number}"
							rendered="#{loginManaged.currentUser.role.role == 'ROLE_ECR_CONSULTANT' 
							|| loginManaged.currentUser.role.role == 'ROLE_GUEST' 
							|| loginManaged.currentUser.role.role == 'ROLE_AGENCY_CHIEF_WITH_COORDS'}" />

						<br />
						<h:outputText value="#{rail.label}" />
					</div>
					<div id="rl_#{rail.id}" class="rail">
						<!-- Insertion liste des wagons. -->
						<ui:include src="../blocs/inc_wagon.xhtml" />
						<div id="rl_meter_#{rail.id}" class="rail_meters">
							<h:outputText value="#{rail.calcUtilLength}">
								<f:converter converterId="meterConverter" />
							</h:outputText>
							<h:outputText value=" *" rendered="#{rail.utilLengthAlert}" />
						</div>
					</div>
				</ui:repeat>

				<ui:repeat var="rail" value="#{hubManaged.hub.lstCenterRails}">
					<!-- Les voies de triage. -->
					<div id="rc_head_#{rail.id}" class="rail_header_#{rail.available}"
						style="background-color: #{rail.destinationHexColor}">

						<!-- Pour les rôles avec modification. -->
						<a4j:commandLink id="cl_#{rail.id}" execute="@this"
							oncomplete="dhtmlmodal.open('sort', 'iframe', 'sec_manage_sort.jsf', 
							'#{lbl['menu.hub.sort']}', 'width=950px,height=650px,center=1,
							resize=0,scrolling=0');"
							rendered="#{loginManaged.currentUser.role.role == 'ROLE_AGENCY_CHIEF' 
							|| loginManaged.currentUser.role.role == 'ROLE_COORDINATOR'}">
							<h:outputText value="#{lbl['hub.rail']} #{rail.number}" />
							<f:setPropertyActionListener target="#{hubManaged.currentRail}"
								value="#{rail}" />
						</a4j:commandLink>

						<!-- Pour les rôles sans modification. -->
						<h:outputText value="#{lbl['hub.rail']} #{rail.number}"
							rendered="#{loginManaged.currentUser.role.role == 'ROLE_ECR_CONSULTANT' 
							|| loginManaged.currentUser.role.role == 'ROLE_GUEST' 
							|| loginManaged.currentUser.role.role == 'ROLE_AGENCY_CHIEF_WITH_COORDS'}" />

						<br />
						<h:outputText value="#{rail.destinationLabel}" />
						<h:outputText value="#{rail.label}" />
					</div>
					<div id="rc_#{rail.id}" class="rail">
						<!-- Insertion liste des wagons. -->
						<ui:include src="../blocs/inc_wagon.xhtml" />
						<div id="rc_meter_#{rail.id}" class="rail_meters">
							<h:outputText value="#{rail.calcUtilLength}">
								<f:converter converterId="meterConverter" />
							</h:outputText>
							<h:outputText value=" *" rendered="#{rail.utilLengthAlert}" />
						</div>
					</div>
				</ui:repeat>

				<ui:repeat var="rail" value="#{hubManaged.hub.lstRightRails}">
					<!-- Les voies de formation. -->
					<div id="rr_head_#{rail.id}"
						class="rail_header_small_#{rail.available}">

						<!-- Pour les rôles avec modification. -->
						<a4j:commandLink id="cl_#{rail.id}" execute="@this"
							oncomplete="dhtmlmodal.open('sort', 'iframe', 'sec_manage_sort.jsf', 
							'#{lbl['menu.hub.sort']}', 'width=950px,height=650px,center=1,
							resize=0,scrolling=0');"
							rendered="#{loginManaged.currentUser.role.role == 'ROLE_AGENCY_CHIEF' 
							|| loginManaged.currentUser.role.role == 'ROLE_COORDINATOR'}">
							<h:outputText value="#{lbl['hub.rail']} #{rail.number}" />
							<f:setPropertyActionListener target="#{hubManaged.currentRail}"
								value="#{rail}" />
						</a4j:commandLink>

						<!-- Pour les rôles sans modification. -->
						<h:outputText value="#{lbl['hub.rail']} #{rail.number}"
							rendered="#{loginManaged.currentUser.role.role == 'ROLE_ECR_CONSULTANT' 
							|| loginManaged.currentUser.role.role == 'ROLE_GUEST' 
							|| loginManaged.currentUser.role.role == 'ROLE_AGENCY_CHIEF_WITH_COORDS'}" />
						<br />
						<h:outputText value="#{rail.label}" />
					</div>
					<div id="rr_#{rail.id}" class="rail">
						<!-- Insertion liste des wagons. -->
						<ui:include src="../blocs/inc_wagon.xhtml" />
						<div id="rr_meter_#{rail.id}" class="rail_meters">
							<h:outputText value="#{rail.calcUtilLength}">
								<f:converter converterId="meterConverter" />
							</h:outputText>
							<h:outputText value=" *" rendered="#{rail.utilLengthAlert}" />
						</div>
					</div>
				</ui:repeat>
			</h:panelGrid>
		</a4j:outputPanel>
	</h:form>

	<!-- Fonction pour la demande de rafraichissement du hub. -->
	<!-- Aucune action n'est demandée on fait juste un rafraichissement de 'hub_panel'. -->
	<a4j:jsFunction name="refreshHub" immediate="true" render="hub_panel" />

	<!-- Fonction pour le rafraîchissement complet (avec demande accès base).-->
	<a4j:poll action="#{hubManaged.refreshHub}" interval="300000"
		render="hub_panel"
		rendered="#{loginManaged.currentUser.role.role == 'ROLE_ECR_CONSULTANT' 
							|| loginManaged.currentUser.role.role == 'ROLE_GUEST' 
							|| loginManaged.currentUser.role.role == 'ROLE_AGENCY_CHIEF_WITH_COORDS'}" />

</ui:composition>
</html>